package com.ljq.software_springboot.softwareprogram.imp;

import com.ljq.software_springboot.softwareprogram.entity.ChatMessage;
import com.ljq.software_springboot.softwareprogram.mapper.ChatMessageMapper;
import com.ljq.software_springboot.softwareprogram.service.IChatMessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.message.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-12-29
 */
@Service
public class ChatMessageServiceImpl extends ServiceImpl<ChatMessageMapper, ChatMessage> implements IChatMessageService {
    @Autowired
    private ChatMessageMapper messageMapper;

    public void saveMessage(ChatMessage message) {
        message.setTimestamp(System.currentTimeMillis());
        messageMapper.insert(message);
    }

    public List<ChatMessage> getMessages(String userId, String recipientId) {
        List<ChatMessage> chatMessages=getBaseMapper().getMessages(userId, recipientId);
        return chatMessages;
    }
}
